#include <stdio.h>

#define Max(a,b) ((a)>(b)?(a):(b))

long long maximumSubarraySum(int* nums, int numsSize, int k) {
    long long sum=0,max=0;
    int diffCnt=0;
    int cT[100001]={ [ 1 ... 100000 ]=0 };    
    for( int i=0 ; i < numsSize; i++ ){
        sum+=nums[i];
        if( cT[ nums[i] ]++ == 0 )
            diffCnt++;
        if( i < k-1 )
            continue;
        if( diffCnt == k )
            max=Max(max,sum);
        sum-=nums[ i-k+1 ];
        if( --cT[ nums[i-k+1] ] == 0 )
            diffCnt--;
    }
    return max;
}


int main(){
    int nums[]={4,4,4};
    printf("%lld\n",maximumSubarraySum(nums,sizeof(nums)/sizeof(int),
        3));
    return 0;
}
